package com.liu.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    /**
     * 单独发布  批量发布队列
     * @return
     */
    @Bean
    public Queue queue(){
        return new Queue("simple-queue");
    }

    @Bean
    public DirectExchange directExchange(){
        return new DirectExchange("simple-ex");
    }

    @Bean
    public Binding binding(DirectExchange directExchange,Queue queue){
        return BindingBuilder.bind(queue).to(directExchange).with("simple");
    }

    @Bean
    public Queue asyncQueue(){
        return new Queue("async-queue");
    }

    @Bean
    public DirectExchange asyncExchange(){
        return new DirectExchange("async-ex");
    }

    @Bean
    public Binding asyncBinding(DirectExchange asyncExchange,Queue asyncQueue){
        return BindingBuilder.bind(asyncQueue).to(asyncExchange).with("async");
    }


}
